<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head th:replace="adminCommon::common-header"></head>
<body class="sb-nav-fixed bg-cover" th:style="'background-image: url(/img/tianjiabeijingtu.jpeg)'">
<nav th:replace="adminCommon::common-navbar"></nav>
<div id="layoutSidenav">
  <div th:replace="adminCommon::common-sidenav"></div>

  <div id="layoutSidenav_content">
    <main>
      <div class="container-fluid px-4">
        <h1 class="mt-4">添加产品</h1>

        <ol class="breadcrumb mb-4">
          <li class="breadcrumb-item"><a th:href="@{/toAdminMain}">主页</a></li>
          <li class="breadcrumb-item"><a th:href="@{/product/selProduct}">产品管理</a></li>
          <li class="breadcrumb-item active">添加产品</li>
        </ol>

        <div class="card mb-4 table">

          <form th:action="@{/product/addProduct}" method="post" name="addForm"
                onsubmit="return beforeSubmit(this)">
            <table class="table table-hover">
              <tr>
                <td text-align="center">产品名称：</td>
                <td><input type="text" class="form-control" placeholder="名称" name="productName">
                </td>
              </tr>
              <tr>
                <td text-align="center">产品型号：</td>
                <td><input type="text" class="form-control" placeholder="型号" name="productModel">
                </td>
              </tr>
            </table>
            <div style="display:flex;justify-content:center;align-items:center;gap:20px;margin:30px 0;">
              <input type="submit" class="btn btn-outline-success" value="添加">
              <a th:href="@{/product/selProduct}" class="btn btn-secondary">
                <i class="fas fa-arrow-left"></i> 返回
              </a>
            </div>
          </form>
        </div>
      </div>
    </main>
    <footer th:replace="adminCommon::common-footer"></footer>
  </div>
</div>

<div th:include="adminCommon::common-scripts"></div>
<script type="text/javascript">
  function beforeSubmit(addForm) {
    if (addForm.productName.value == "") {
      alert("请输入产品名称！")
      return false;
    }
    if (addForm.productModel.value == "") {
      alert("请输入产品型号！")
      return false;
    }
    return true;
  }
</script>
</body>
</html>
